function fingerprint(): string {
  const canvas = document.createElement('canvas');

  const ctx = canvas.getContext('2d');
  if (ctx) {
    ctx.fillStyle = '#FC9630';
    ctx.fillRect(0, 0, 8, 8);
    const base64 = canvas.toDataURL().replace('data:image/png;base64,', '');
    return bin2hex(window.atob(base64).slice(-16, -12));
  }

  return '';
}

function bin2hex(s = '') {
  const _s = s + '';
  const f = _s.length,
    a = [];

  for (let i = 0; i < f; i++) {
    a[i] = _s
      .charCodeAt(i)
      .toString(16)
      .replace(/^([\da-f])$/, '0$1');
  }

  return a.join('');
}

export { fingerprint };
